<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('漫画篇章页数列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse" hidden>
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>漫画id：</label>
                            <input type="text" name="nameId" th:value="${nameId}"/>
                        </li>
                        <li>
                            <label>章节id：</label>
                            <input type="text" name="chapterId" th:value="${chapterId}"/>
                        </li>
                        <li>
                            <label>图片地址：</label>
                            <input type="text" name="src"/>
                        </li>
                        <li>
                            <label>图片顺序：</label>
                            <input type="text" name="srcOrder"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="manhua:page:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="manhua:page:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="manhua:page:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="manhua:page:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('manhua:page:edit')}]];
    var removeFlag = [[${@permission.hasPermi('manhua:page:remove')}]];

    var prefix = ctx + "manhua/page";
    /*请求数据临时存放*/
    let data = [];

    $(function() {
        let nameId = $("input[name='nameId']").val()?$("input[name='nameId']").val():'';
        let chapterId = $("input[name='chapterId']").val()?$("input[name='chapterId']").val():'';
        var options = {
            url: prefix + "/list",
            queryParams: queryParams,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            /*pagination:false,*/
            modalName: "漫画篇章页",
            columns: [{
                checkbox: false
            },
                {
                    field: 'nameId',
                    title: '漫画id',
                    formatter: function (value, row, index) {
                        return $.common.reale({value: "第"+value+"部漫画", numder: 2});
                    }
                },
                {
                    field: 'chapterId',
                    title: '章节id',
                    formatter: function (value, row, index) {
                        return $.common.reale({value: value, numder: 1});
                    }
                },
                {
                    field: 'chapter',
                    title: '章节',
                    formatter: function (value, row, index) {
                        return $.common.reale({value: value, numder: 1});
                    }
                },
                {
                    field: 'src',
                    title: '图片地址',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'srcOrder',
                    title: '图片顺序',
                    formatter: function (value, row, index) {
                        return $.common.reale({value:"第"+value+"页", numder: 2});
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                       // console.log(row)
                        data.push(row);
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="look()"><i class=""></i>观看</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function queryParams(params) {
        let search = $.table.queryParams(params);
        search.nameId = [[${nameId}]];
        search.chapterId = [[${chapterId}]];
        return search;
    }

    let look = () => {

        let nameId = $("input[name='nameId']").val()?$("input[name='nameId']").val():'';
        let chapterId = $("input[name='chapterId']").val()?$("input[name='chapterId']").val():'';

        const url = prefix+"/look/"+nameId+"/"+chapterId;

        $.modal.openOptions({
            url:url,
            title:"观看",
            height:($(window).height()),
            width:($(window).width()/2),
            btn:false
        });

    }




</script>
</body>
</html>
